

#include "WiFi.h"

int bounds[128];
int index = 0;
int end1 = 1;
int end2 = 1;
int end3 = 1;
int end4 = 1;

void WiFi::connect()
{
	serialMode(serialMode_self);					// Talk to wifi
	Serial.println("AT+WD");
	Serial.write("AT+NDHCP=1");						// Turn on DHCP
	Serial.write("AT+WA=ENGINEERING,,11");					// Connect to ENGINEERING wifi
	Serial.write("AT+HTTPCONF=20,User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9");
	Serial.write("AT+HTTPCONF=3,close");
	Serial.write("AT+HTTPCONF=11,128.119.91.47");
	Serial.write("AT+HTTPOPEN=128.119.91.47");		// Open an HTTP connection
	Serial.write("AT+HTTPSEND=0,1,10,/ece/sdp/sdp12/burleson/boundaryFiles/bounds.txt");	// Retrieve bounds
	serialMode(serialMode_wifi);					// Listen to the wifi
}

bool WiFi::encode(int b)
{
	bounds[index] = b;
	index++;
	end4 = end3;
	end3 = end2;
	end2 = end1;
	end1 = b;
	if(end1+end2+end3+end4 == 0)
	{
		index -= 4;
		return true;
	}
	return false;
}